package com.free.semantic.req;

import com.free.semantic.common.RelationInstance;
import com.free.semantic.common.RelationItem;
import com.free.semantic.core.ConceptManage;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class RelationDefine {

    private String name;

    private List<RelaItemDef> relaItemDefs;

    public RelationInstance buildRelationInstance(Map<String, String> variableMap, ConceptManage conceptManage) {
        RelationInstance instance = new RelationInstance(name);
        List<RelationItem> relationItems = new ArrayList<>();
        for (RelaItemDef relaItemDef : relaItemDefs) {
            RelationItem relationItem = relaItemDef.buildInstance(variableMap, conceptManage);
            relationItem.setParentInstance(instance);
            relationItems.add(relationItem);
        }
        instance.setRelationItems(relationItems);
        return instance;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<RelaItemDef> getRelaItemDefs() {
        return relaItemDefs;
    }

    public void setRelaItemDefs(List<RelaItemDef> relaItemDefs) {
        this.relaItemDefs = relaItemDefs;
    }

}
